<layout name="layout" />
<style type="text/css">
.share {
	float: right;
}
fieldset.business_review_comment ul.checkbox li p.tit {
	width: 260px;
}
fieldset.business_review_comment ul.checkbox li p.field {
	width: 650px;
}
</style>
<section class="wrapper marc content">
  <header>
    <figcaption>{$vo.shop_name}</figcaption>
  </header>
  <dl>
    <dt><img src="{$vo.shop_thumb|default='__PUBLIC_DC__/skin/img/content_img.jpg'}" width="480" height="312" alt="" /></dt>
    <dd>
      <p><span class="tit">评级</span><span class="star star_{$vo.shop_score|intval}"></span></p>
      <p><span class="tit">口味</span><span>{$vo.shop_kouwei|default="暂无"}</span></p>
      <p class="description"><span class="tit">描述</span><span class="content">{$vo.shop_desc|default="暂无"}</span></p>
      <p><span class="tit">价位</span><span>{$vo.shop_price|default="暂无"}</span></p>
      <p><span class="tit">点评</span><span>{$vo.shop_reply_num|format_int}</span></p>
      <a class="order" href="{:U('Cai/index/',array('shop_id'=>$vo['shop_id']))}">查看菜单</a> </dd>
  </dl>
</section>
<section class="wrapper marc content_comment business_review">
  <section class="left l">
    <figcaption>网友评论</figcaption>
    <php> $where_var = "reply_connect = ".$vo['shop_id']." AND reply_type = '店铺'"; </php>
    <getData model="Reply" field="*" name="reply" id="row" limit="5" where_var="$where_var" order="reply_id DESC">
      <dl class="list">
        <dt><a href="javascript:void(0);"><img src="__PUBLIC_DC__/skin/img/content_avatar.jpg" width="65" height="65" alt="" /></a></dt>
        <dd class="user">
          <p><a href="javascript:void(0);">{$row.reply_user_name|default="游客"}</a></p>
          <span class="star star_{$row.reply_score}"></span> </dd>
        <dd class="content">
          <p>{$row.reply_content}</p>
          <div class="share"> 
            
            <!-- JiaThis Button BEGIN -->
            <div class="jiathis_style"> <a class="jiathis_button_qzone"></a> <a class="jiathis_button_tsina"></a> <a class="jiathis_button_tqq"></a> <a class="jiathis_button_weixin"></a> <a class="jiathis_button_renren"></a> <a class="jiathis_button_xiaoyou"></a> <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a> <a class="jiathis_counter_style"></a> </div>
            <script type="text/javascript" >
			var jiathis_config={
				summary:"{$row.reply_content}",
				title:"{$vo.shop_name}",
				hideMore:false
			}
			</script> 
            <script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script> 
            <!-- JiaThis Button END --> 
            
          </div>
          <div class="clear"></div>
        </dd>
      </dl>
    </getData>
  </section>
  <section class="right r">
    <figcaption>商家公告</figcaption>
    <p>{$vo.shop_notice|default="暂无公告"}</p>
  </section>
</section>
<div class="clear"></div>
<fieldset class="wrapper marc business_review_comment">
  <legend>您的评论</legend>
  <ul class="wrapper checkbox">
    <li>
      <p class="tit">送餐时间</p>
      <p class="field time">
        <input type="radio" id="time_10" name="time" value="10" />
        <label for="time_10">10分钟</label>
        <input type="radio" id="time_20" name="time" value="20" />
        <label for="time_20">20分钟</label>
        <input type="radio" id="time_30" name="time" value="30" />
        <label for="time_30">30分钟</label>
        <input type="radio" id="time_40" name="time" value="40" />
        <label for="time_40">40分钟</label>
        <input type="radio" id="time_50" name="time" value="50" />
        <label for="time_50">50分钟</label>
        <input type="radio" id="time_60" name="time" value="60" />
        <label for="time_60">一小时</label>
      </p>
    </li>
    <li>
      <p class="tit">外送人员态度</p>
      <p class="field score">
        <input type="radio" id="score_1" name="out_score" value="1" />
        <label for="score_1">1分</label>
        <input type="radio" id="score_2" name="out_score" value="2" />
        <label for="score_2">2分</label>
        <input type="radio" id="score_3" name="out_score" value="3" />
        <label for="score_3">3分</label>
        <input type="radio" id="score_4" name="out_score" value="4" />
        <label for="score_4">4分</label>
        <input type="radio" id="score_5" name="out_score" value="5" />
        <label for="score_5">5分</label>
        <input type="radio" id="score_6" name="out_score" value="6" />
        <label for="score_6">6分</label>
        <input type="radio" id="score_7" name="out_score" value="7" />
        <label for="score_7">7分</label>
        <input type="radio" id="score_8" name="out_score" value="8" />
        <label for="score_8">8分</label>
        <input type="radio" id="score_9" name="out_score" value="9" />
        <label for="score_9">9分</label>
        <input type="radio" id="score_10" name="out_score" value="10" />
        <label for="score_10">10分</label>
      </p>
    </li>
  </ul>
  <textarea id="reply_content"></textarea>
  <p id="grade_star" class="grade">
    <button class="r" id="reply_submit">发表评论</button>
    <span>您的评分</span><a href="javascript:void(0);"></a><a href="javascript:void(0);"></a><a href="javascript:void(0);"></a><a href="javascript:void(0);"></a><a href="javascript:void(0);"></a> </p>
</fieldset>
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
  var time = $(":checkbox[name='time']"),
    score = $(":checkbox[name='score']");
  $("ul.checkbox :checkbox").each(function(i, checkbox) {
    checkbox = $(checkbox);
    checkbox.click(function() {
      switch (checkbox.attr("name")) {
        case "time":
          time.attr("checked", false);
          break;
        case "score":
          score.attr("checked", false);
          break;
      }
      checkbox.attr("checked", true);
    });
  });

  // 评分星星
  var grade = $("#grade_star > a"),
    grade_1 = grade.eq(0),
    grade_2 = grade.eq(1),
    grade_3 = grade.eq(2),
    grade_4 = grade.eq(3),
    grade_5 = grade.eq(4);
  grade_1.click(function() {
    grade_1.addClass("active");
    grade_2.removeClass("active");
    grade_3.removeClass("active");
    grade_4.removeClass("active");
    grade_5.removeClass("active");
  });
  grade_2.click(function() {
    grade_1.addClass("active");
    grade_2.addClass("active");
    grade_3.removeClass("active");
    grade_4.removeClass("active");
    grade_5.removeClass("active");
  });
  grade_3.click(function() {
    grade_1.addClass("active");
    grade_2.addClass("active");
    grade_3.addClass("active");
    grade_4.removeClass("active");
    grade_5.removeClass("active");
  });
  grade_4.click(function() {
    grade_1.addClass("active");
    grade_2.addClass("active");
    grade_3.addClass("active");
    grade_4.addClass("active");
    grade_5.removeClass("active");
  });
  grade_5.click(function() {
    grade_1.addClass("active");
    grade_2.addClass("active");
    grade_3.addClass("active");
    grade_4.addClass("active");
    grade_5.addClass("active");
  });
});
$(document).ready(function(e) {
  $("#reply_submit").click(function() {
    var time = $('input:radio[name="time"]:checked').val();
    if (time == null) {
      alert("请选择送餐时间!");
      return false;
    }
    var out_score = $('input:radio[name="out_score"]:checked').val();
    if (out_score == null) {
      alert("请选择外送人员态度!");
      return false;
    }
    var reply_content = $("#reply_content").val();
    if (reply_content == "") {
      alert("请填写您的评价");
      return false;
    }
    var score = $("#grade_star > a.active").length;
    if (score == 0) {
      alert("请选择您的评分!");
      return false;
    }
    jQuery.ajax({
      url: '{:U("Reply/insert")}',
      type: 'POST',
      dataType: 'json',
      data: {
        'reply_type': '店铺',
        'reply_connect':'{$vo.shop_id}',
        'reply_score': score,
        'reply_score_ext1': time,
        'reply_score_ext2': out_score,
        'reply_content': reply_content
      },
      success: function(data, textStatus, xhr) {
         alert(data['info']);
         if (data['status'] == 1){
            window.location.reload();
         }
      },
      error: function(xhr, textStatus, errorThrown) {
        //called when there is an error
      }
    });


    })
  });
//]]>
</script> 
